package user;

import book.BookList;
import operation.*;

import java.util.Scanner;


public class AdminUser extends User {
    {//实例代码块来初始化 operations 通过 operations 来实现对不同的 choice 有不同的行为(并且还区分了不同的用户)
        super.operations = new Operation[]{
                new ExitOperation(),
                new AddOperation(),
                new DelOperation(),
                new FindOperation(),
                new AmendOperation(),
                new DisplayOperation()
        };
    }

    public AdminUser(String name) {
        super(name);
    }

    @Override
    public int menu() {
        System.out.println(name + " 欢迎来到图书管理小练习!");
        System.out.println("**********************************************");
        System.out.println("1.增添一本书");
        System.out.println("2.下架一本书");
        System.out.println("3.查找一本书");
        System.out.println("4.修改一本书");
        System.out.println("5.显示所有书");
        System.out.println("0.退出系统");
        System.out.println("**********************************************");
        System.out.println("请选择操作：");
        Scanner scanner = new Scanner(System.in);
        return scanner.nextInt();
    }

    @Override
    public void operation(int pos, BookList bookList) {
        Operation operation = this.getOperation(pos);
        if (operation != null) {
            operation.work(bookList);
        }
    }

}
